package com.ihr360.payroll.test.mock;

import com.google.common.collect.ImmutableList;
import com.ihr360.payroll.model.dto.attendance.plan.AttendancePlan;
import com.ihr360.payroll.model.dto.attendance.rule.SalaryAdjustWorkHourConfig;
import com.ihr360.payroll.model.dto.attendance.rule.enroll.EnrollAdjustRule;
import com.ihr360.payroll.model.dto.attendance.rule.enroll.EnrollAdjustRuleWorkHourConfig;
import com.ihr360.payroll.model.dto.attendance.rule.overtime.OvertimeRule;
import com.ihr360.payroll.model.dto.attendance.rule.overtime.OvertimeRuleWorkHourConfig;
import com.ihr360.payroll.model.dto.attendance.rule.personalleave.PersonalLeaveRule;
import com.ihr360.payroll.model.dto.attendance.rule.personalleave.PersonalLeaveRuleWorkHourConfig;
import com.ihr360.payroll.model.dto.attendance.rule.sickleave.SickLeaveRule;
import com.ihr360.payroll.model.dto.attendance.rule.sickleave.SickLeaveRuleWorkHourConfig;
import com.ihr360.payroll.service.payroll.mock.core.AttendancePlanHelper;
import com.ihr360.payroll.service.payroll.mock.core.SalaryFieldHelper;
import com.ihr360.payroll.type.BasementType;

public class AttendancePlanAdvanceHelper extends AttendancePlanHelper {
    public static AttendancePlan attendancePlan() {
        AttendancePlan plan = new AttendancePlan();

        OvertimeRuleWorkHourConfig workhourConfig = getOvertimeRuleWorkHourConfig();
        OvertimeRule overtimeRule = getOvertimeRule();
        plan.setOvertimeConfig(workhourConfig);
        plan.setOvertimeRule(overtimeRule);


        SickLeaveRuleWorkHourConfig sickLeaveRuleWorkHourConfig = getSickLeaveRuleWorkHourConfig();
        SickLeaveRule sickLeaveRule = getSickLeaveRule();

        plan.setSickLeaveConfig(sickLeaveRuleWorkHourConfig);
        plan.setSickLeaveRule(sickLeaveRule);

        PersonalLeaveRuleWorkHourConfig personalLeaveRuleWorkHourConfig = getPersonalLeaveRuleConfig();
        PersonalLeaveRule personalLeaveRule = getPersonLeaveRule();

        plan.setPersonalLeaveConfig(personalLeaveRuleWorkHourConfig);
        plan.setPersonalLeaveRule(personalLeaveRule);

        plan.setEnrollAdjustConfig(getEnrollAdjustRuleWorkHourConfig());
        plan.setEnrollAdjustRule(getEnrollAdjustRule());

        plan.setSalaryAdjustConfig(getSalaryAdjustConfig());
        return plan;
    }

    private static PersonalLeaveRuleWorkHourConfig getPersonalLeaveRuleConfig() {
        PersonalLeaveRuleWorkHourConfig config = new PersonalLeaveRuleWorkHourConfig();
        config.setDailyWorkCount(800);
        config.setMonthWorkCount(2175);
        return config;
    }

    private static PersonalLeaveRule getPersonLeaveRule() {
        PersonalLeaveRule rule = new PersonalLeaveRule();
        rule.setBaseRatio(100d);//基数比例
        rule.setNumOpRatio(100d);//扣款比例
        rule.setReferenceFields(ImmutableList.of(SalaryFieldHelper.basesalary(), SalaryFieldHelper.positionallowance(), SalaryFieldHelper.positionsalary()));
        rule.setBasementType(BasementType.REFERENCE);
        return rule;
    }

    protected static SickLeaveRule getSickLeaveRule() {
        SickLeaveRule rule = new SickLeaveRule();
        rule.setBaseRatio(100d);//基数比例
        rule.setNumOpRatio(100d);//扣款比例
        rule.setReferenceFields(ImmutableList.of(SalaryFieldHelper.basesalary(), SalaryFieldHelper.positionallowance(), SalaryFieldHelper.positionsalary()));
        rule.setBasementType(BasementType.REFERENCE);
        return rule;
    }

    protected static SickLeaveRuleWorkHourConfig getSickLeaveRuleWorkHourConfig() {
        SickLeaveRuleWorkHourConfig sickLeaveRuleWorkHourConfig = new SickLeaveRuleWorkHourConfig();
        sickLeaveRuleWorkHourConfig.setDailyWorkCount(800);
        sickLeaveRuleWorkHourConfig.setMonthWorkCount(2175);
        return sickLeaveRuleWorkHourConfig;
    }

    protected static OvertimeRuleWorkHourConfig getOvertimeRuleWorkHourConfig() {
        OvertimeRuleWorkHourConfig workhourConfig = new OvertimeRuleWorkHourConfig();
        workhourConfig.setDailyWorkCount(800);
        workhourConfig.setMonthWorkCount(2175);
        return workhourConfig;
    }

    protected static EnrollAdjustRuleWorkHourConfig getEnrollAdjustRuleWorkHourConfig() {
        EnrollAdjustRuleWorkHourConfig config = new EnrollAdjustRuleWorkHourConfig();
        config.setDailyWorkCount(800);
        config.setMonthWorkCount(2200);
        return config;
    }

    protected static EnrollAdjustRule getEnrollAdjustRule() {
        EnrollAdjustRule rule = new EnrollAdjustRule();
        rule.setFixedBase(20000d);
        rule.setReferenceFields(ImmutableList.of(SalaryFieldHelper.basesalary(), SalaryFieldHelper.positionallowance(), SalaryFieldHelper.positionsalary()));
        rule.setBasementType(BasementType.REFERENCE);
        return rule;
    }

    protected static SalaryAdjustWorkHourConfig getSalaryAdjustConfig(){
        SalaryAdjustWorkHourConfig config = new SalaryAdjustWorkHourConfig();
        config.setDailyWorkCount(800);
        config.setMonthWorkCount(2200);
        return config;
    }

    protected static OvertimeRule getOvertimeRule() {
        OvertimeRule rule = new OvertimeRule();
        rule.setHolidayRatio(300d);//法定比例
        rule.setWeekendRatio(200d);//节假日比例
        rule.setBaseRatio(100d);//基数比例

        rule.setNumOpRatio(150d);//计算比例
        rule.setFixedBase(20000d);//固定基数
        rule.setReferenceFields(ImmutableList.of(SalaryFieldHelper.basesalary(), SalaryFieldHelper.positionallowance(), SalaryFieldHelper.positionsalary(), SalaryFieldHelper.senioritypay()));
        rule.setBasementType(BasementType.REFERENCE);
        return rule;
    }
}